// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router';

import Layout from '@/layout/index.vue';

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        component: () => import('@/view/dashboard/Index.vue'),
        name: 'dashboard',
        meta: {
          title: '首页',
          icon: '#icondashboard',
        },
      },
    ],
  },
  {
    path: '/system',
    name: 'system',
    component: Layout,
    meta: {
      title: '系统管理',
      icon: 'Setting',
      roles: ['sys:manage'],
    },
    children: [
      {
        path: 'userList',
        component: () => import('@/view/system/user/UserList.vue'),
        name: 'userList',
        meta: {
          title: '用户管理',
          icon: 'UserFilled',
          roles: ['sys:user'],
        },
      },
      {
        path: 'roleList',
        component: () => import('@/view/system/role/RoleList.vue'),
        name: 'roleList',
        meta: {
          title: '角色管理',
          icon: 'Wallet',
          roles: ['sys:role'],
        },
      },
      {
        path: 'menuList',
        component: () => import('@/view/system/menu/MenuList.vue'),
        name: 'menuList',
        meta: {
          title: '菜单管理',
          icon: 'Menu',
          roles: ['sys:menu'],
        },
      },
    ],
  },
  {
    path: '/goodsRoot',
    component: Layout,
    name: 'goodsRoot',
    meta: {
      title: '商品管理',
      icon: 'Setting',
      roles: ['sys:goodsRoot'],
    },
    children: [
      {
        path: 'category',
        component: () => import('@/view/category/CategoryList.vue'),
        name: 'category',
        meta: {
          title: '商品类型',
          icon: 'UserFilled',
          roles: ['sys:category'],
        },
      },
      {
        path: 'goodsList',
        component: () => import('@/view/goods/GoodsList.vue'),
        name: 'goodsList',
        meta: {
          title: '商品信息',
          icon: 'Wallet',
          roles: ['sys:goodsList'],
        },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
